package org.footito.android.data.update;

import org.footito.android.R;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class BootReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

		try {
			int value = Integer.parseInt(prefs.getString(
					context.getResources().getString(R.string.prefs_frequency_key), "0"));
			if (value > 0) {
				UpdateService.scheduleService(context, value);
			} else {
				UpdateService.unScheduleService(context);
			}
		} catch (Exception e) {
		}
	}

}
